home *** CD-ROM | disk | FTP | other *** search
/ Power Bytes: Money & Finance / PowerBytes Money and Finance CD-ROM 01 / PowerBytes Money and Finance CD-ROM 01.iso / MacII / IFSFractals / IFS.doc < prev    next >
Encoding:
Text File  |  1988-03-28  |  4.8 KB  |  80 lines  |  [TEXT/ttxt]

  1. ITERATED FUNCTION SYSTEM   --  by A.P. Maika  88/03/28
  2. ------------------------------------------------------
  3.  
  4. OFFICIAL STUFF:
  5.  
  6. Written in Lightspeed C¬ by THINK Technologies Inc. (version 2.15)
  7.  
  8. Written with the aid of SimpleTools ⌐ by Erik Kilk 1986.
  9.  
  10. SimpleTools is shareware and is on GENIE in the MacDevelopers Library (page 481) as file number 419 under the name SIMPLETOOLS2.PIT. Unpack with PackIt.
  11.  
  12.  
  13. INCLUDED FILES:
  14.  
  15. This package consists of four files:
  16.  
  17.           - "IFS Fractals", the standalone application
  18.           - "IFS.doc", text explanatory file
  19.           - "IFS.p" Lightspeed C condensed project file
  20.           - "IFS.c" Lightspeed C source code
  21.  
  22.  
  23. PROGRAM OPERATION:
  24.  
  25. The program "IFS Fractals" uses affine transformations to reconstruct fractals as an attractor as described in Barnsley, M.F., Sloan, A.D., "A Better Way to Compress Images", BYTE (January 1988) 215-223.
  26.  
  27. To run the program, start up the application and select "Iterate 5,000x" or Cmd-I to iterate 5,000 times. On a Mac SE with a built-in hard drive 5,000 iterations take just over 2 minutes. This command may be repeated as often as desired. The iteration counter and pixel counter appearing on the bottom of the screen are cumulative. Note that calling up the "About IFS..." or "Extra Info" alert windows will wipe out the pixels underneath the window, so don't call these windows up unless you have finished with your processing of the reconstructed image. You may wish to save images at various stages of reconstruction. This is of course possible using Cmd-Shift-3 to create a MacPaint image. 
  28.  
  29. There are six possible fractal images which may be reconstructed. On opening the application, the Sierpinski Triangle transformations are active. The particular image desired is chosen by selecting one of the images listed under the "Commands" menu item. The chosen image is indicated by the checkmark beside the image. When a new image is selected the iteration counter and pixel counter are reset to zero. The following images have been included in the program:
  30.  
  31.           Image               Keyboard Command          No. of Transforms
  32.           -----               ----------------          -----------------
  33.  
  34.           Dragon                    Cmd-D                       4
  35.           Fern                      Cmd-F                       4
  36.           Spiral                    Cmd-P                       2
  37.           Square                    Cmd-S                       4
  38.           Tree                      Cmd-R                       4
  39.           Sierpinski Triangle       Cmd-T                       3    
  40.  
  41. Some images, for example the fern and the dragon, require quite a large number of iterations (say 50,000) before they become dark, but all images are recognizable almost immediately.
  42.  
  43.  
  44. AFFINE TRANSFORMATIONS:
  45.  
  46. As explained in the Barnsley, Sloan article, another way to reconstruct a fractal is as an attractor for a set of contractive affine transformations. An affine transformation is a linear mapping from the point (x,y) to f(x,y)=(X,Y) and may be expressed as follows:
  47.  
  48.                           X = a*x + b*y + e
  49.  
  50.                           Y = c*x + d*y + f
  51.  
  52. In the Barnsley, Sloan article, the above transform is designated by a 7-number set:
  53.                           [ a b c d e f p ]
  54.           
  55. Where "p" is the probability associated with the transform.
  56.  
  57. Certain types of fractals may be encoded as a set of such transforms. For example, the Sierpinski triangle fractal may be encoded in three such transforms as follows:
  58.  
  59.                   [ 0.5  0.0  0.0  0.5  0.0  0.0  0.333 ] 
  60.  
  61.                   [ 0.5  0.0  0.0  0.5  1.0  0.0  0.333 ]
  62.  
  63.                   [ 0.5  0.0  0.0  0.5  0.5  0.5  0.334 ]
  64.  
  65. The program simply iterates through the transforms randomly choosing one transform per iteration in accordance with its probability of appearance and computes (X,Y). The location of the pixel to be placed on the screen is determined by applying scaling and offset factors to (X,Y) so that a reasonably sized and centred image appears on the screen. For the Sierpinski triangle above, the scaling and offset factors are:
  66.  
  67.                               xscale = 245.0
  68.                              xoffset =   5.0
  69.                               yscale = 270.0
  70.                              yoffset =   5.0
  71.  
  72. Hence, (x,y) (80 bit floating point numbers) maps to (X,Y) from applying one of the above transforms (also maintained as 80 bit floating point numbers) and finally maps to integers (XX,YY):
  73.  
  74.                               XX = 245*X + 5
  75.                               YY = 270*Y + 5 
  76.  
  77. Pixel (XX,YY) (window coordinates) is then set to black.
  78.  
  79. Note that the fractal image appears as a whole and not by microscopic parts as is most often the way these images are constructed. Since the set of transforms "represent" the fractal, the fractal is encoded in an extremely small amount of information. 
  80.